package com.xy.annotaion.handler.interceptor;

import com.xy.annotaion.handler.common.log.LogService;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * cglib 原生 拦截器
 *
 * @author Dell
 */
public class TestCglibMethodInterceptor implements MethodInterceptor, LogService {
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
//        Pointer.lg("public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable");
//        Object ret = methodProxy.invoke(o,objects);
//        Pointer.lg("end");

        //errror o is proxy,so call toString stack overflow
        //
//        Pointer.lg(o);
//        System.out.println(o);
        log(method);
        log(objects);
        log(methodProxy);

        return methodProxy.invokeSuper(o, objects);

    }
}
